import Vue from 'vue'
import Vuex from 'vuex'
import menus from "./inc/menus";

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        token: '',
        tabList: []
    },
    mutations: {
        SET_TOKEN: (state, token) => {
            state.token = token
            localStorage.setItem("token", token)
        },
        addTab: (state, tab) => {
            // 如果tab已经存在，不添加新的tabs
            if (state.tabList.some(item => item.path === tab.path))return
            state.tabList.push(tab)
        },
    },
    getters:{
        //获取tabList
        getTabs:(state) =>{
            return state.tabList
        }
    },
    actions: {},
    modules: {
        //添加额外的模块，叫menus
        menus
    }
})
